package com.hlg.xboot.config;

import com.digi_zones.common.alipay.AlipayService;
import com.digi_zones.common.aliyun.opensearch.OpenSearchService;
import com.digi_zones.common.aliyun.oss.OSSService;
import com.digi_zones.common.aliyun.sms.SMSService;
import com.digi_zones.common.wechat.TokenHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.core.RedisTemplate;

/**
 * <p>Description: 配置Spring Bean，与xml中的<bean></bean>配置一致</p>
 * <p>Copyright: Copyright (c) 2016</p>
 * <p>Company: 中视数讯</p>
 * <p>Site: www.digi-zones.com</p>
 * <p>myblog: http://blog.csdn.net/xyang81</p>
 *
 * @author 杨信
 * @version 1.0
 * @date 2016/10/31
 */
@Configuration
public class BeanConfig {

    @Autowired
    private AppConfig appConfig;

    @Autowired
    private RedisTemplate<String,Object> template;

    /**
     * 阿里云OSS存储服务
     *
     * @return
     */
    @Bean
    public OSSService ossService() {
        return new OSSService(appConfig.getAliyun());
    }

    /**
     * 阿里云短信服务
     *
     * @return
     */
    @Bean
    public SMSService smsService() {
        return new SMSService(appConfig.getAliyun());
    }

    /**
     * 阿里云开放搜索服务
     * @return
     */
    @Bean
    public OpenSearchService openSearchService() {
        return new OpenSearchService(appConfig.getAliyun());
    }

    /**
     * 微信Token工具接口
     * @return
     */
    @Bean
    public TokenHelper tokenHelper() {
        return new TokenHelper(template,appConfig.getWeixin());
    }

    @Bean
    public AlipayService alipayService() {
        return new AlipayService(appConfig.getAlipay());
    }

}
